// ==UserScript==
// @name         微拍堂链接助手
// @namespace http://git.oschina.net/baOZe/userscript
// @updateURL http://git.oschina.net/baOZe/userscript/raw/master/%E5%BE%AE%E6%8B%8D%E5%A0%82%E9%93%BE%E6%8E%A5%E5%8A%A9%E6%89%8B.user.js?dir=0&filepath=%E5%BE%AE%E6%8B%8D%E5%A0%82%E9%93%BE%E6%8E%A5%E5%8A%A9%E6%89%8B.user.js
// @version      1.0
// @description  微拍堂网页在Chrome浏览器中无法用新tab弹出商品，也无法直接复制链接。修改之后点击商品图片可以在新tab打开，商品标题可以复制链接
// @author       baOZe
// @match        https://w.weipaitang.com/category/detail/*
// @run-at       document-start
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    document.addEventListener('DOMContentLoaded', function(){
        var saleItemTemplateDesc = $("#saleItemTemplate .desc");
        var $newDesc = $("<a>{desc}</a>");
        saleItemTemplateDesc.html("<a href='/uri/{uri}?r=category'>{desc}</a>");
        window.wptRedirect = function(url, time){
            time = typeof time == 'undefined' ? ($.os.android ? 200 : 0) : time;
            if (time > 0) {
                setTimeout(function() {
                    $(document).trigger("wptLoading_view:hide");
                    window.open(url);
                }, time);
            } else {
                $(document).trigger("wptLoading_view:hide");
                window.open(url);
            }
        };
    }, false);
})();